import { request } from "../../request/index"

Page({
  data: {
    //轮播图
    swiperList: [],
    // 导航 数组
    catesList: [],
    // 楼层数组
    floorList: []
  },
  //页面开始加载就会 触发
  onLoad: function (options) {
    // 1、发送异步请求获取轮播图数据
    // var reqTask = wx.request({
    // url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
    // data: {},
    // header: { 'content-type': 'application/json' },
    // method: 'GET',
    // dataType: 'json',
    // responseType: 'text',
    // success: (result) => {
    //   // console.log(result);
    //   this.setData({
    //     swiperList: result.data.message
    //   })
    // },
    // });
    this.getSwiperList();
    this.getCatesList();
    this.getFloorList();

  },
  //获取轮播图数据
  getSwiperList() {
    request({ url: "/home/swiperdata" })
      .then(result => {
        this.setData({
          swiperList: result.data.message
        })
      })
  },
  //获取分类导航
  getCatesList() {
    request({ url: "/home/catitems" })
      .then(result => {
        this.setData({
          catesList: result.data.message
        })
      })
  },
  getFloorList() {
    request({ url: "/home/floordata" })
      .then(result => {
        this.setData({
          floorList: result.data.message
        })
      })
  }
});